package com.app.stick.visit.controller;

import java.util.List;

import com.app.common.interfaces.Add;
import com.app.common.interfaces.Edit;
import com.app.stick.visit.domain.vo.BizPatientVisitAddOrEditVo;
import com.app.stick.visit.domain.vo.BizPatientVisitListVo;
import com.app.stick.visit.domain.vo.BizPatientVisitQueryVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.app.common.annotation.Log;
import com.app.common.core.controller.BaseController;
import com.app.common.core.domain.ApiResult;
import com.app.common.enums.BusinessType;
import com.app.stick.visit.domain.BizPatientVisit;
import com.app.stick.visit.service.IBizPatientVisitService;

/**
 * 患者就诊信息Controller
 *
 * @author app
 * @date 2023-12-16
 */
@Api(value = "患者就诊信息", tags = {"WEB-患者就诊信息接口"})
@RestController
@RequestMapping("/visit/info")
public class BizPatientVisitController extends BaseController
{
    @Resource
    private IBizPatientVisitService bizPatientVisitService;

    /**
     * 查询患者就诊信息列表
     */
    @ApiOperation("查询患者就诊信息列表")
    @GetMapping("/list")
    public ApiResult<List<BizPatientVisitListVo>> list(BizPatientVisitQueryVo queryVo)
    {
        startPage();
        List<BizPatientVisitListVo> list = bizPatientVisitService.selectBizPatientVisitList(queryVo);
        return ApiResult.page(list, new PageInfo(list).getTotal());
    }

    /**
     * 获取患者就诊信息详细信息
     */
    @ApiOperation("获取患者就诊信息详细信息")
    @ApiImplicitParam(name = "visitId", value = "患者就诊信息ID", dataType = "String", dataTypeClass = String.class, required = true)
    @GetMapping(value = "/getInfo/{visitId}")
    public ApiResult<BizPatientVisit> getInfo(@PathVariable("visitId") String visitId)
    {
        return ApiResult.ok(bizPatientVisitService.selectBizPatientVisitByVisitId(visitId));
    }

    /**
     * 新增患者就诊信息
     */
    @ApiOperation("新增患者就诊信息")
    @Log(title = "患者就诊信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public ApiResult<Integer> add(@Validated(Add.class) @RequestBody BizPatientVisitAddOrEditVo addOrEditVo)
    {
        return ApiResult.toR(bizPatientVisitService.insertBizPatientVisit(addOrEditVo));
    }

    /**
     * 修改患者就诊信息
     */
    @ApiOperation("修改患者就诊信息")
    @Log(title = "患者就诊信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public ApiResult<Integer> edit(@Validated(Edit.class) @RequestBody BizPatientVisitAddOrEditVo addOrEditVo)
    {
        return ApiResult.toR(bizPatientVisitService.updateBizPatientVisit(addOrEditVo));
    }

    /**
     * 删除患者就诊信息
     */
    @ApiOperation("删除患者就诊信息")
    @ApiImplicitParam(name = "visitIds", value = "患者就诊信息ID", dataType = "String[]", dataTypeClass = String[].class, required = true)
    @Log(title = "患者就诊信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{visitIds}")
    public ApiResult<Integer> remove(@PathVariable("visitIds") String[] visitIds)
    {
        return ApiResult.toR(bizPatientVisitService.deleteBizPatientVisitByVisitIds(visitIds));
    }
}
